//! # Lumos Vector Qdrant
//!
//! Qdrant vector database implementation for the lumos-vector-core architecture.
//!
//! This crate provides a high-performance Qdrant backend for vector storage,
//! implementing the unified VectorStorage trait from lumos-vector-core.
//!
//! ## Features
//!
//! - **High Performance**: Leverages Qdrant's optimized vector search
//! - **Scalability**: Supports distributed Qdrant clusters
//! - **Rich Filtering**: Advanced metadata filtering capabilities
//! - **Batch Operations**: Efficient bulk insert and update operations
//! - **Connection Pooling**: Optimized connection management
//!
//! ## Example
//!
//! ```rust
//! use lumos_vector_qdrant::QdrantVectorStorage;
//! use lumos_vector_core::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     // Create Qdrant storage
//!     let storage = QdrantVectorStorage::new("http://localhost:6334").await?;
//!
//!     // Create an index
//!     let config = IndexConfig::new("documents", 384)
//!         .with_metric(SimilarityMetric::Cosine);
//!     storage.create_index(config).await?;
//!
//!     // Insert documents
//!     let docs = vec![
//!         Document::new("doc1", "Hello world")
//!             .with_embedding(vec![0.1; 384])
//!             .with_metadata("type", "greeting"),
//!     ];
//!     storage.upsert_documents("documents", docs).await?;
//!
//!     // Search
//!     let request = SearchRequest::new("documents", vec![0.1; 384])
//!         .with_top_k(5);
//!     let results = storage.search(request).await?;
//!
//!     Ok(())
//! }
//! ```

pub mod config;
pub mod error;
pub mod filter;
pub mod storage;

pub use config::QdrantConfig;
pub use error::QdrantError;
pub use storage::QdrantVectorStorage;

// Re-export core types for convenience
pub use lumosai_vector_core::prelude::*;

/// Create a new Qdrant vector storage instance
pub async fn create_qdrant_storage(url: &str) -> Result<QdrantVectorStorage> {
    QdrantVectorStorage::new(url).await
}

/// Create a new Qdrant vector storage instance with configuration
pub async fn create_qdrant_storage_with_config(
    config: QdrantConfig,
) -> Result<QdrantVectorStorage> {
    QdrantVectorStorage::with_config(config).await
}

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_create_storage() {
        // This test requires a running Qdrant instance
        // Skip if not available
        if std::env::var("QDRANT_URL").is_err() {
            return;
        }

        let url =
            std::env::var("QDRANT_URL").unwrap_or_else(|_| "http://localhost:6334".to_string());
        let storage = create_qdrant_storage(&url).await;

        // Should either succeed or fail with connection error
        match storage {
            Ok(_) => println!("Successfully connected to Qdrant"),
            Err(e) => println!("Failed to connect to Qdrant: {e}"),
        }
    }
}
